let search=document.querySelector('#inp')
let content=document.querySelector('#content')
function jsonp(url) {
  //先创建一个script标记
  let script = document.createElement('script')
  //把地址赋值
  script.src = url
  //把创建的标记放body标记里面
  document.body.appendChild(script)
}
function fn(res){
  content.innerHTML = ''
  res.s.forEach((item)=>{
      content.innerHTML += `
          <li>${item}</li>
      `
  })
}
onkeyup = ()=>{
  content.innerHTML = ''
  let wd = search.value
  if(wd.trim().length == 0){
      content.innerHTML = ''
      return
  }
  jsonp(`https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?cb=fn&wd=${wd}`)
}

let sign=document.querySelector('.sign')
let login=document.querySelector('.login')
let quit=document.querySelector('.quit')
for(let i=0;i<localStorage.length;i++){
  sign.innerHTML='欢迎用户：'+localStorage.key(i)
  if(sign.innerHTML==='欢迎用户：'+localStorage.key(i)){
    login.style.display='none'
    quit.style.display='block'
  }
}
login.onclick=()=>{
  location.href='http://127.0.0.1:2113/html/login.html'
}